package Demo_Old.First;

import java.io.IOException;
import java.util.Objects;

public class TryTest{
	public static void main(String[] args) throws IOException {
//		try {
//			FileInputStream inputStream=new FileInputStream("java");
//		} catch (FileNotFoundException e) {
//			e.printStackTrace();
//		}
		//int a=test();
		//System.out.println(test());
//		try {
//			show();
//		}catch (GenderException e){
//			//e.printStackTrace();
//			System.out.println("genderException");
//		}
//		catch (ArithmeticException e){
//
//		}catch (Exception e) {
//			//e.printStackTrace();
//			System.out.println("exception");
//		}

//		try {
//			show();
//		} catch (GenderException e) {
//			e.printStackTrace();
//		}
		//	requireNnNull("");
		show();
	}

	public static String requireNnNull(String obj) throws InterruptedException {
		if (obj == null)
			throw new InterruptedException();
		return obj;
	}

	public static int  show()  {
		String gender="123";
		if(!gender.equals("man")){
			try {
				try {
					int i=1/0;
					throw new GenderException("性别异常");
				} catch (GenderException e) {
					System.out.println("第一层try");
				}finally {
					System.out.println("finally结束");
				}
			}catch (ArithmeticException e){
				System.out.println("外层try");
			}

		}
//		System.out.println("222");
		return 10;
	}

	public void use(){
		//show();
		test();
	}

	private static int test()throws NullPointerException{
		int s=10;
		String sd=null;
		Objects.requireNonNull(sd,"");
		try{
			System.out.println("try");
			return s+=80;
		}catch(NullPointerException e){
			System.out.println("error");
		}finally{
			if (s > 20){
				System.out.println("s>20 : " + s);
			}
			int r=10/0;
			System.out.println("finally");
			s = 100;
			//return s;
		}
		return s;
	}
}

class Num{
	public int num = 10;
}